﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using COM.OA.BLL;

public partial class showdepartment : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Request.Params["ft"] != null)
        {
            int ft = Int32.Parse(this.Request.Params["ft"]);
            SeachFileType(ft);
        }
        if (this.Request.Params["dt"] != null)
        { 
            int dt =Int32.Parse( this.Request.Params["dt"]);
            SeachDept(dt);
        }
        if (this.Request.Form["q"] != null)
        {
            string t = this.Request.Form["q"];
            SeachT(t);
        }
       
        
    }

    
    protected void SeachT(string t)
    {
        //模糊查询的各个条件
        string f_where = "f_isshare =1 and f_filename like '%" + t + "%' or ";

        string ft_where = " f_ftype_id in (select ftype_id from filetype where ftype_filetype like '%"+t+"%') ";

        string d_where = " or f_dept_id in (select dept_id from department where dept_department like '%" +t+ "%') or ";

        string u_where =" f_sendu_id in (select u_id from users where u_em_id in(select em_id from employee where em_name like '%"+t+"%'))";

        string where = f_where + ft_where + d_where + u_where;

        IList<COM.OA.Entity.files> fileList = filesBLL.Select(where,true,false);
        Session.Add("fileLists",fileList);
    }
    //根据文件类型查询
    protected void SeachFileType(int ft)
    {
        string where = "f_isshare =1 and f_ftype_id =" + ft;
        IList<COM.OA.Entity.files> fileList = filesBLL.Select(where, true, false);
        Session.Add("fileLists", fileList);
    }
    //根据部门查询所属文件
    protected void SeachDept(int dt)
    {
        string where = "f_isshare=1 and f_dept_id =" + dt;
        IList<COM.OA.Entity.files> fileList = filesBLL.Select(where, true, false);
        Session.Add("fileLists", fileList);
    }
}
